﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "newformulawidget.h"
#include "submitproductwidget.h"
#include "changepasswordwidget.h"
#include "joincompanywidget.h"
#include "userservice.h"
#include "userrelationservice.h"
#include "combinesplitwidget.h"
#include "companyservice.h"
#include "productservice.h"
#include "newfinancewidget.h"
#include "editfinancesubject.h"
#include "addfinancesubject.h"
#include "productpicker.h"
#include "userpicker.h"
#include "messageservice.h"
#include "financeservice.h"
#include "dingdanservice.h"
#include "homecountwidget.h"
#include "uploadwidget.h"
#include "messagepicker.h"
#include "ticketmoneyadjustwidget.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void initAfterLoginOK();

    void closeEvent(QCloseEvent *ev);

signals:
    void showLogin();

private slots:
    //初始化主界面点击事件
    void initHomeSubWidgetClickEvent();
    //初始化个人信息状态
    void initPersonalInfo();
    //初始化企业信息状态
    void initCompanyInfo();
    //初始化企业信息页面状态
    void initCompanyInfoWidgetState();
    //初始化商品页面状态
    void initProductPageState();
    //初始化销售页面状态
    void initSalePageState();
    //初始化采购页面状态
    void initPurchasePageState();
    //初始化消息页面状态
    void initMessagePageState();
    //初始化财务页面状态
    void initFinancePageState();
    //初始化老板页面状态
    void initBossPageState();

    void messagePageSelectUser();

    void on_actionHome_triggered();

    void on_actionSaleOut_triggered();

    void on_actionSaleBack_triggered();

    void on_actionClientManage_triggered();

    void on_actionSaleQuery_triggered();

    void on_actionSaleHistory_triggered();

    void on_actionPurchaseIn_triggered();

    void on_actionPurchaseBack_triggered();

    void on_actionGiverManage_triggered();

    void on_actionPurchaseQuery_triggered();

    void on_actionPurchaseOrder_triggered();

    void on_actionProductStocks_triggered();

    void on_actionProductPlan_triggered();

    void on_actionProductCount_triggered();

    void on_actionProductSplit_triggered();

    void on_actionProductLibrary_triggered();

    void on_actionTicketOut_triggered();

    void on_actionMoneyIn_triggered();

    void on_actionTicketIn_triggered();

    void on_actionMoneyOut_triggered();

    void on_actionFinanceKeep_triggered();

    void on_actionBossQuery_triggered();

    void on_actionProfitQuery_triggered();

    void on_actionFinanceQuery_triggered();

    void on_actionTicketAdjust_triggered();

    void on_actionCompanyInfo_triggered();

    void on_actionPersonalInfo_triggered();

    void on_actionBatch_triggered();

    void on_actionMessage_triggered();

    void on_pushButtonNewFormula_clicked();

    void on_pushButtonCombine_clicked();

    void on_pushButtonSplit_clicked();

    void on_labelBtnAdd_clicked();

    void on_pushButtonNewProduct_clicked();

    void on_pushButtonEditProduct_clicked();

    void on_pushButtonChangePwd_clicked();

    void on_pushButtonChangeOpPwd_clicked();

    void on_pushButtonSaveUser_clicked();

    void on_pushButtonNewCompany_clicked();

    void on_pushButtonSaveCompany_clicked();

    void on_pushButtonUpdateProductData_clicked();

    void on_pushButtonJoinCompany_clicked();

    void on_lineEditProductOverallQuery_textChanged(const QString &arg1);

    void on_lineEditProductTypeQuery_textChanged(const QString &arg1);

    void on_lineEditProductNameQuery_textChanged(const QString &arg1);

    void on_pushButtonProductClearQuery_clicked();

    void on_pushButtonNewFinance_clicked();

    void on_pushButtonFinanceSubjectAdd_clicked();

    void on_pushButtonImportClient_clicked();

    void on_pushButtonImportGiver_clicked();

    void on_pushButtonImportProduct_clicked();

    void on_pushButtonUpdateFormula_clicked();

    void on_pushButtonProductPlanNew_clicked();

    void on_pushButtonProductCountClear_clicked();

    void on_pushButtonProductCountSubmit_clicked();

    void on_pushButtonProductLibraryStoreOut_clicked();

    void on_pushButtonProductLibraryStoreIn_clicked();

    void on_pushButtonSaleHistoryClear_clicked();

    void on_pushButtonBossUpdateCompanyData_clicked();

    void on_pushButtonMessageUpdateData_clicked();

    void on_comboBoxMessageType_currentIndexChanged(int index);

    void on_pushButtonMessageClear_clicked();

    void on_pushButtonFinanceRefresh_clicked();

    void on_pushButtonFinanceSubjectEdit_clicked();

    void on_comboBoxTicketAdjustType_currentIndexChanged(int index);

    void on_pushButtonTicketAdjustQuery_clicked();

    void on_pushButtonTicketAdjustClear_clicked();

    void on_lineEditTicketAdjustTicketChangeValue_editingFinished();

    void on_lineEditTicketAdjustMoneyChangeValue_editingFinished();

    void on_pushButtonTicketAdjustTicketReset_clicked();

    void on_pushButtonTicketAdjustMoneyReset_clicked();

    void on_pushButtonTicketAdjustTicketSubmit_clicked();

    void on_pushButtonTicketAdjustMoneySubmit_clicked();

    void on_pushButtonSaleHistoryQuery_clicked();

    void on_pushButtonSaleHistorySubmitChange_clicked();

    void on_pushButtonPurchaseOrderSend_clicked();

    void on_pushButtonFinanceQueryClear_clicked();

    void on_pushButtonFinanceQueryStart_clicked();

    void on_comboBoxFinanceQueryType1_currentIndexChanged(int index);

    void on_pushButtonBossQueryTicketCount_clicked();

    void on_pushButtonBossQueryMoneyCount_clicked();

    void on_pushButtonTicketAdjustTicketImport_clicked();

    void on_pushButtonTicketAdjustMoneyImport_clicked();

    void on_dateEditFinanceQueryStartTime_dateChanged(const QDate &date);

    void on_dateEditFinanceQueryEndTime_dateChanged(const QDate &date);

    void on_comboBoxProduct_currentIndexChanged(int index);

    void on_lineEditTicketAdjustTicketChangeValue_textEdited(const QString &arg1);

    void on_lineEditTicketAdjustMoneyChangeValue_textEdited(const QString &arg1);
private:
    Ui::MainWindow *ui;
    bool showExitMsg;

    UserService userService;
    CompanyService companyService;
    ProductService productService;
    UserRelationService userRelationService;
    MessageService messageService;
    FinanceService financeService;
    DingdanService dingdanService;

    CombineSplitWidget combineWidget;
    CombineSplitWidget splitWidget;
    NewFormulaWidget newFormulaWidget;

    SubmitProductWidget newProductWidget;
    SubmitProductWidget updateProductWidget;
    ChangePasswordWidget changePasswordWidget;
    JoinCompanyWidget joinCompanyWidget;

    HomeCountWidget homeCountWidget;
    UploadWidget uploadWidget;
    TicketMoneyAdjustWidget ticketMoneyAdjustWidget;

    MessagePicker messagePicker;

    NewFinanceWidget newFinanceWidget;
    AddFinanceSubject addFinanceSubject;
    EditFinanceSubject editFinanceSubject;

    ProductPicker productPicker;
    UserPicker clientPicker;
    UserPicker giverPicker;
    UserPicker adjustTicketUserPicker;
    UserPicker messageUserPicker;

    UserRelation *messageSelectedUserRelation;
    UserRelation *saleHistorySelectedUserRelation;
    Product *saleHistorySelectedProduct;

    UserRelation *purchaseOrderSelectedUserRelation;

    UserRelation *adjustTicketUserRelation;
    QList<QStringList> financeQueryTypes;

    QDate lastFinanceQueryStartDate;
    QDate lastFinanceQueryEndDate;
};

#endif // MAINWINDOW_H
